[Top] [Prev] [Next] [Bottom]
[Contents]
Debugging Server Applications
You can debug your server application using your current debug tools since the server applications are written in C/C++. Sapphire/Web offers several aids in debugging. When debugging a server application, the program is run from the project directory at the UNIX command line or from within the debugger. The debugger run is xxgdb
which uses gdb
. Both of these are free, the latter from gnu. The steps described use these tools.
To debug a server application which is processing an Anchor Activator, you need to get the query string. The first way to get this is to look at the HTML source for the calling Anchor and get the part of the HREF after the question mark character. For example if the anchor looks like this:
<A HREF=
"http://cezanne/cgibin/table//table.cgi?FNC=tcreate__
Atdemo_html">
Create Table</A>
then the QUERY_STRING is:
FNC=tcreate__Atdemo_html
A second technique is to set the Project Option, "Print Environment" to True.
- 1. Rebuild your server application.
- 2. Click on the Calling Anchor.
- 3. In the resulting HTML source get the value of the QUERY_STRING environment.
- 4. Now to use the QUERY_STRING value do the following.
- 5. Start the debugger with your server application.
xxgdb table.cgi
- where
table.CGI
is the name of your server application.
- 6. Then break points are set.
- 7. Start the server application in the debugger using the QUERY_STRING as:
run table.cgi FNC=tcreate__Atdemo_html
- where the last parameter is the QUERY_STRING. You may need to perform shell escaping, depending on content.
- 8. If you also want to set up the environment to try to match what the server application will see when launched from http, you will need to capture the environment.
- If you already set "Print Environment" as described previously, then you can grab the entire environment from the returned HTML source, then paste it into a file, e.g.
ENV
.
- 9. To use that file, start the CGI in the debugger with
run table.cgi FNC=tcreate__Atdemo_html -env ENV
- The order of arguments is important.
Of course there are still several differences with the debug run and the real server application. First, the user for the real server application is usually "nobody". In the debugger it's you. You may be fooled by permissions on files and directories. Second, the debugger CGI has other environment variables that the real server application does not. Third, unless the HTML and CGI bin directories are mounted, the debug server application will run in the starting directory.
To debug form-activated CGIs you need to do the following. Set the Project Option, Print Form Args
to True
. Rebuild your server application. Fill in and activate the Calling Form. In the resulting HTML source get the form arguments. Paste these into a file, e.g. ARGS
. To use that file to start the server application in the debugger with:
run table.cgi -debug ARGS
You can also use the environment, getting it as described above, with:
run table.cgi -debug ARGS -env ENV
or
run table.cgi -env ENV -debug ARGS
The environment and argument information printed out are HTML-compatible strings and may need some "decoding".
You can also get more debug information from the real server application using a code purification tool such as PurifyTM. Link the server application with this tool and run the purified version. Then look at the resulting log file. Permissions must be set for the user "nobody" to write this log file.
[Top] [Prev] [Next] [Bottom]
[Contents]
info@bluestone.com
Copyright © 1997, Bluestone. All rights
reserved.